home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / progutil / stdwin.zoo / test / vtdemo.c < prev   
C/C++ Source or Header  |  1989-10-17  |  999b  |  46 lines

  1. #include "stdwin.h"
  2. #include "vt.h"
  3.  
  4. main() {
  5.     VT *vt;
  6.     winit();
  7.     wsetdefwinsize(80*wcharwidth('0'), 24*wlineheight());
  8.     vt= vtopen("VT", 24, 80, 100); /* Should check outcome */
  9.     vtautosize(vt);
  10.     vtsetnlcr(vt, 1); /* Map LF ro CR LF */
  11.     vtansiputs(vt, "Hello, world\n", -1);
  12.     eventloop();
  13.     wdone();
  14.     exit(0);
  15. }
  16.  
  17. eventloop(vt) VT *vt; {
  18.     for (;;) {
  19.         EVENT e;
  20.         wgetevent(&e);
  21.         switch (e.type) {
  22.         case WE_SIZE:
  23.             vtautosize(vt); /* Should check outcome */
  24.             break;
  25.         case WE_CHAR:
  26.             { char buf[2];
  27.               buf[0]= e.u.character;
  28.               vtansiputs(vt, buf, 1);
  29.               break; }
  30.         case WE_MOUSE_DOWN:
  31.             vtsetcursor(vt,
  32.                         e.u.where.v / vtcheight(vt),
  33.                         e.u.where.h / vtcwidth(vt));
  34.             break;
  35.         case WE_COMMAND:
  36.             switch (e.u.command) {
  37.             case WC_CLOSE:                              return;
  38.             case WC_RETURN: vtansiputs(vt, "\n", 1);    break;
  39.             case WC_BACKSPACE: vtansiputs(vt, "\b", 1); break;
  40.             case WC_TAB: vtansiputs(vt, "\t", 1);       break;
  41.             }
  42.             break;
  43.         }
  44.     }
  45. }
  46.